package com.ssy.lingxi.marketing.serviceimpl.feign;

import cn.hutool.core.collection.CollectionUtil;
import com.ssy.lingxi.after.sale.api.feign.ReturnGoodsControllerFeign;
import com.ssy.lingxi.after.sale.api.model.vo.request.ReturnDetailReqVO;
import com.ssy.lingxi.after.sale.api.model.vo.response.ReturnGoodsTaxVO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.marketing.service.feign.IAfterSaleFeignService;
import com.ssy.lingxi.marketing.utils.FeignLogUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 *  订单内部接口
 * @author ds
 * @date 2021/12/15
 * @version 2.0.0
 */
@Service
public class AfterSaleFeignServiceImpl implements IAfterSaleFeignService {

    @Resource
    private ReturnGoodsControllerFeign returnGoodsControllerFeign;

    @Override
    public Map<String,ReturnGoodsTaxVO> getOrderInfoMapByExecute(List<Long> orderIds,List<Long> skuIds){
        ReturnDetailReqVO feignVO=new ReturnDetailReqVO();
        feignVO.setOrderIds(orderIds);
        feignVO.setSkuIds(skuIds);
        Wrapper<List<ReturnGoodsTaxVO>> afterSaleOrderStatuses = returnGoodsControllerFeign.getOrderInfoListByIdsAndSkuIds(feignVO);
        FeignLogUtils.printLog("活动执行明细>>批量查询订单状态",afterSaleOrderStatuses,feignVO);
        if(CollectionUtil.isNotEmpty(afterSaleOrderStatuses.getData())){
            return afterSaleOrderStatuses.getData().stream().collect(Collectors.toMap(k->k.getOrderId()+":"+k.getSkuId(), o2->o2,(o1, o2)->o1));
        }
        return null;
    }

}